<?php

namespace app\app\model\shop;

use think\Model;

class BoardModel extends Model
{
    protected $name = 'board';

    public const STATUS_AVAILABLE = 100; //空闲中
    public const STATUS_OCCUPIED = 200; //使用中

    public const STATUS_ARRAY_TEXT = [
        self::STATUS_AVAILABLE => 'Available',
        self::STATUS_OCCUPIED => 'Occupied',
    ];


    // 追加属性
    protected $append = [
        'status_text'
    ];


    public function list($params)
    {
        return $this->where('shop_id',$params['shop_id'])
            ->field('number,status,shop_id')
            ->select();
    }


    public function getStatusList()
    {
        return  self::STATUS_ARRAY_TEXT;
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ?: ($data['status'] ?? '');
        $list = $this->getStatusList();
        return $list[$value] ?? '';
    }
}